package com.zy.baselib

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.sudworth.themvp.view.AppDelegate

/**
 * 最简单的基类，UI操作写在activity里面
 * 不支持依赖注入，会报错。
 */
abstract class BaseAct<B: ViewBinding>: BaseDiVAct<BaseAct.EmptyDelegate<B>>() {

    private lateinit var mViewBinding: B

    init {
        viewDelegate = object : EmptyDelegate<B>() {
            override fun onCreateViewBinding(inflater: LayoutInflater, container: ViewGroup?): B {
                mViewBinding = onCreateVB(inflater, container)
                return mViewBinding
            }
        }
    }

    abstract fun onCreateVB(inflater: LayoutInflater, container: ViewGroup?): B

    abstract class EmptyDelegate<B: ViewBinding>: AppDelegate<B>()

    fun getViewBinding(): B {
        return mViewBinding
    }
}